package com.ngc.mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ngc.mall.domain.MessageRecordDomain;
import com.ngc.mall.vo.MessageRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageRecordMappper extends BaseMapper<MessageRecordDomain> {

    ///查看所有公告
    @Select({"SELECT c.*,IFNULL(r.status,0) AS status,u.nickname as send_name\n" +
            "FROM message_content c \n" +
            "left join user u ON (c.send_id=u.id)\n" +
            "LEFT JOIN message_record r \n" +
            "ON (c.id = r.message_id AND r.receive_id =#{uid}) where c.notice_type=2 ORDER BY c.create_time DESC;"})
    List<MessageRecordVO> getAllNoticeByMySelf(Long uid);


    @Select({"SELECT c.*,r.status AS status\n" +
            "FROM message_record r \n" +
            "LEFT JOIN message_content c \n" +
            "ON (c.id = r.message_id AND r.receive_id = #{uid}) WHERE c.notice_type=1 ORDER BY c.create_time DESC;"})
    List<MessageRecordVO> getAllSingleChartByMySelf(Long uid);
}
